/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skytestarmor;

import java.io.IOException;
import java.util.Collection;
import lev.debug.LDebug;
import ru.jSkyRoom.support.GrupTypeBuilder;
import skyproc.ENCH;
import skyproc.Mod;
import skyproc.SPGlobal;
import skyproc.SPImporter;
import skyproc.exceptions.NotFound;
import skyproc.gui.SPDefaultGUI;

/**
 *
 * @author Dima
 */
public class KArmor {

    private static SPDefaultGUI gui;

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        SPGlobal.createGlobalLog();
        try {

            Mod patch = new Mod("KRArmor", false);
            patch.setAuthor("Kepper");
            SPGlobal.setGlobalPatch(patch);
            SPGlobal.pathToData = "C:\\Steam\\SteamApps\\common\\skyrim\\Data\\";


            gui = new SPDefaultGUI("KRArmor",
                    "KRArmor");

            GrupTypeBuilder grupTypeBuilder = new GrupTypeBuilder();
            grupTypeBuilder.Armor().Enchantment().FormList().Keyword();
//            grupTypeBuilder.ALL();
            SPImporter.importActiveMods(grupTypeBuilder.build());

            createMod();
            patch.export();

            gui.finished();

        } catch (Exception e) {
            e.printStackTrace();
            LDebug.wrapUp();
        }

        LDebug.wrapUp();
    }

    public static void createMod() throws NotFound, IOException {
        /*
         Mod patch = SPGlobal.getGlobalPatch();

         SyntaticModBuilder syntaticModBuilder = new SyntaticModBuilder();
         syntaticModBuilder.add("Skyrim.esm", "Update.esm", "Dragonborn.esm", "Dawnguard.esm");
         //        syntaticModBuilder.add("Kepper_Radiant_LB_test.esp", "KR_WeaponPack.esp");
         Mod merger = syntaticModBuilder.build();

         //        EnbhantmentsBank enbhantmentsBank = new EnbhantmentsBank(merger);
         GeneralFactory generalFactory = new GeneralFactory(merger);
         LinkerFactory linkerFactory = generalFactory.createLinkerFactory();
         KeyWordEnchantmentsLinker keyWordEnchantmentsLinker = linkerFactory.createKeyWordEnchantmentsLinker(loadBaseEnchantment(merger));
         Map<KYWD, ArrayList<ENCH>> keyWordEnchantmentsLinks = keyWordEnchantmentsLinker.getLinks();
         RecordFinderFactory recordFinderFactory = generalFactory.createRecordFinderFactory();
         RecordFinder<KYWD> recordProducer = recordFinderFactory.createKYWD();
         KYWD keyWord = recordProducer.find("0006C0EC", "Skyrim.esm");
         //        Map<String, ENCH> res = enbhantmentsBank.getEnchListByKeyword(enchID);
         for (ARMO armo : merger.getArmors()) {
         ENCH echantment = keyWordEnchantmentsLinks.get(keyWord).get(0);
         armo.setEnchantment(echantment.getForm());
         patch.addRecord(armo);
         }
         */
    }

    private static Collection<ENCH> loadBaseEnchantment(Mod mod) {

        Collection<ENCH> enchantments = mod.getEnchantments().getRecords();
        /* Filter<ENCH> enchantmentsFilter = FilterFactory.create("(?!EnchWeapon)(.*)(Base)");
         Collection<ENCH> enchantments = enchantmentsFilter.filter(allEnchantments);*/
        return enchantments;
    }
}
